package Amazon;

import Amazon.ListLoop.ListNode;

public class MergeList {
	
	public static ListNode mergelist(ListNode l1, ListNode l2){
		ListNode head = new ListNode(0);
        ListNode cur = head;
        while(l1!=null && l2!=null){
            if(l1.value<=l2.value){
                cur.next=l1;
                l1=l1.next;
            }
            else{
                cur.next=l2;
                l2=l2.next;
            }
            cur=cur.next;
        }
        
        if(l1==null) 
            cur.next = l2;
        else
            cur.next=l1;
        return head.next;
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
